
proc rec-ack-event {e} {
}

proc rec-terminate {n} {
   exit
}


proc select-line {line col color} {
   unselect-line
   .w.text tag add    highlight "$line.0" "$line.0 + 1 lines"
   .w.text tag configure highlight -background $color
   .w.text mark set insert "$line.$col"
}

proc unselect-line {} {
   .w.text tag remove highlight 0.0 end
}


proc set-text {text} {
   unselect-line
   .w.text delete 0.0 end
   .w.text insert end [TCLstring $text]
}

proc get-text {} {
   set text [.w.text get 0.0 end]
   set text [string trimright $text "\n"]
   set text "$text\n"
   TBsend "snd-value(get-text([TBstring $text]))"
}

proc text-modified {} {
   TBevent text-modified
}

proc create {} {
   frame .w

   wm title . "Pico Editor"
   text .w.text \
      -yscrollcommand ".w.vs set" \
      -relief ridge \
      -bd 1 \
      -width 40

   scrollbar .w.vs\
      -orient vertical \
      -command ".w.text yview"

   pack .w.text \
      -side left \
      -fill both \
      -expand 1
   pack .w.vs \
        -side left \
        -fill both

   pack .w -fill both

  bind .w.text <Any-Key> "text-modified"

}

create
